<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions"
      xmlns:hr="http://java.sun.com/jsf/composite/autocomplete">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">
                <h:form >
                    <p:panel >
                        <f:facet name="header" >
                            <h:outputLabel value="Shift Amendments" />
                        </f:facet>
                        <h:panelGrid columns="2" >
                            <h:outputLabel value="From : " />
                            <p:calendar value="#{hrReportController.fromDate}" pattern="dd MMMM yyyy hh:mm:ss a" />
                            <h:outputLabel value="To : " />
                            <p:calendar value="#{hrReportController.toDate}" pattern="dd MMMM yyyy hh:mm:ss a" />
                            <h:outputLabel value="Institution : "/>
                            <hr:institution value="#{hrReportController.reportKeyWord.institution}"/>
                            <h:outputLabel value="Department : "/>
                            <hr:department value="#{hrReportController.reportKeyWord.department}"/>
                            <h:outputLabel value="Employee : "/>
                            <hr:completeStaff value="#{hrReportController.reportKeyWord.staff}"/>
                            <h:outputLabel value="Staff Category : "/>
                            <hr:completeStaffCategory value="#{hrReportController.reportKeyWord.staffCategory}"/>
                            <h:outputLabel value="Designation : "/>
                            <hr:completeDesignation value="#{hrReportController.reportKeyWord.designation}"/>
                            <h:outputLabel value="Roster : "/>
                            <hr:completeRoster value="#{hrReportController.reportKeyWord.roster}"/>
                            <h:outputLabel value="Shift : "/>
                            <hr:completeShift value="#{hrReportController.reportKeyWord.shift}"/>
                        </h:panelGrid>

                        <p:commandButton ajax="false" value="Process" action="#{hrReportController.createStaffShiftHistory()}"/>
                        <p:commandButton ajax="false" value="Excel" styleClass="noPrintButton" onclick="onSubmitButton();" >
                            <pe:exporter type="xlsx" target="tb1" fileName="hr_report_staff_shift_history"  />
                        </p:commandButton>
                        <p:commandButton value="Print" ajax="false" action="#" >
                            <p:printer target="gpBillPreview" ></p:printer>
                        </p:commandButton>
                        <p:panel id="gpBillPreview" styleClass="noBorder summeryBorder" >                     

                            <p:dataTable id="tb1" value="#{hrReportController.staffShiftHistorys}" var="ss"
                                         rows="20"
                                         paginator="true"
                                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                         rowsPerPageTemplate="10,20,50"
                                         >
                                <f:facet name="header">
                                    
                                    <h:outputLabel value="Shift Amendments" /><br/>
                                    <h:outputLabel value="  From : "  />
                                    <h:outputLabel  value="#{hrReportController.fromDate}" >
                                        <f:convertDateTime pattern="dd MM yy "/>
                                    </h:outputLabel>
                                    <h:outputLabel/>
                                    <h:outputLabel/>
                                    <h:outputLabel value="  To : "/> 
                                    <h:outputLabel  value="#{hrReportController.toDate}">
                                        <f:convertDateTime pattern="dd MM yy "/>
                                    </h:outputLabel><br/>
                                    <h:panelGroup rendered="#{hrReportController.reportKeyWord.institution ne null}" >
                                        <h:outputLabel value="#{hrReportController.reportKeyWord.institution.name}" />
                                        <br/>
                                    </h:panelGroup>
                                    <h:panelGroup rendered="#{hrReportController.reportKeyWord.department ne null}" >
                                        <h:outputLabel value="Department : #{hrReportController.reportKeyWord.department.name}"/>
                                        <br/>
                                    </h:panelGroup>
                                    <h:panelGroup rendered="#{hrReportController.reportKeyWord.staff ne null}" >
                                        <h:outputLabel value="Staff : #{hrReportController.reportKeyWord.staff.person.name}"/>
                                        <br/>
                                    </h:panelGroup>
                                </f:facet>

                                <p:columnGroup type="header">
                                    <p:row>
                                        <p:column rowspan="2" headerText="Changed at" sortBy="#{ss.createdAt}"/>
                                        <p:column rowspan="2" 
                                                  headerText="Changed by" 
                                                  sortBy="#{ss.creater.webUserPerson.name}"
                                                  filterBy="#{ss.creater.webUserPerson.name}" 
                                                  filterMatchMode="contains"
                                                  />
                                        <p:column colspan="4" headerText="Changed from" />
                                        <p:column colspan="4" headerText="Changed to" />
                                    </p:row>
                                    <p:row>
                                        <p:column  headerText="Code" 
                                                   sortBy="#{ss.staff.code}"
                                                   filterBy="#{ss.staff.code}" 
                                                   filterMatchMode="contains"/>
                                        <p:column  headerText="Name" 
                                                   sortBy="#{ss.staff.person.nameWithTitle}"
                                                   filterBy="#{ss.staff.person.nameWithTitle}" 
                                                   filterMatchMode="contains"/>
                                        <p:column  headerText="Roster" 
                                                   sortBy="#{ss.roster.name}"
                                                   filterBy="#{ss.roster.name}" 
                                                   filterMatchMode="contains"/>
                                        <p:column  headerText="Shift" 
                                                   sortBy="#{ss.shift.name}"
                                                   filterBy="#{ss.shift.name}" 
                                                   filterMatchMode="contains"/>
                                        <p:column  headerText="Code" 
                                                   sortBy="#{ss.staffShift.staff.code}"
                                                   filterBy="#{ss.staffShift.staff.code}" 
                                                   filterMatchMode="contains"/>
                                        <p:column  headerText="Name" 
                                                   sortBy="#{ss.staffShift.staff.person.nameWithInitials}"
                                                   filterBy="#{ss.staffShift.staff.person.nameWithInitials}" 
                                                   filterMatchMode="contains"/>
                                        <p:column  headerText="Roster" 
                                                   sortBy="#{ss.staffShift.roster.name}"
                                                   filterBy="#{ss.staffShift.roster.name}" 
                                                   filterMatchMode="contains"/>
                                        <p:column  headerText="Shift" 
                                                   sortBy="#{ss.staffShift.shift.name}"
                                                   filterBy="#{ss.staffShift.shift.name}" 
                                                   filterMatchMode="contains"/>
                                    </p:row>
                                </p:columnGroup>

                                <p:column headerText="Changed At" >
                                    <f:facet name="header">
                                        <h:outputLabel value="Changed At"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.createdAt}" >
                                        <f:convertDateTime pattern="dd MMM yy- hh:mm a" ></f:convertDateTime>
                                    </p:outputLabel>
                                </p:column>     

                                <p:column >
                                    <f:facet name="header">
                                        <h:outputLabel value="Changed by"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.creater.webUserPerson.name}" ></p:outputLabel>
                                </p:column>     
                                <p:column >
                                    <f:facet name="header">
                                        <h:outputLabel value="Code"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.staff.code}" ></p:outputLabel>
                                </p:column>   
                                <p:column >
                                    <f:facet name="header">
                                        <h:outputLabel value="Name"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.staff.person.nameWithTitle}" ></p:outputLabel>
                                </p:column>  
                                <p:column >
                                    <f:facet name="header">
                                        <h:outputLabel value="Roster"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.roster.name}" ></p:outputLabel>
                                </p:column>   
                                <p:column >
                                    <f:facet name="header">
                                        <h:outputLabel value="Shift"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.shift.name}" ></p:outputLabel>
                                </p:column>   
                                <p:column >
                                    <f:facet name="header">
                                        <h:outputLabel value="Code"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.staffShift.staff.code}" ></p:outputLabel>
                                </p:column>   
                                <p:column >
                                    <f:facet name="header">
                                        <h:outputLabel value="Name"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.staffShift.staff.person.nameWithInitials}" ></p:outputLabel>
                                </p:column>                                                           
                                <p:column >
                                    <f:facet name="header">
                                        <h:outputLabel value="Roster"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.staffShift.roster.name}" ></p:outputLabel>
                                </p:column>   
                                <p:column >
                                    <f:facet name="header">
                                        <h:outputLabel value="Shift"/>
                                    </f:facet>
                                    <p:outputLabel value=" #{ss.staffShift.shift.name}" ></p:outputLabel>
                                </p:column>  
                                <f:facet name="footer">
                                    <p:outputLabel value="Print By : #{sessionController.loggedUser.webUserPerson.name} - " />
                                    <p:outputLabel value="Print At : " />
                                    <p:outputLabel value="#{commonController.currentDateTime}" >
                                        <f:convertDateTime pattern="yyyy MMMM dd hh:mm:ss a " />
                                    </p:outputLabel>
                                </f:facet>
                            </p:dataTable>




                        </p:panel>


                    </p:panel>

                </h:form>
            </ui:define>

        </ui:composition>

    </h:body>
</html>
